package kr.hyunist.androidcomplete01saeildamil.ch11;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class CountDownEx extends Activity {
	CountDownTimer mTimer;
	TextView tv;
	Button startBtn;
	Button stopBtn;
	float size = 10.0f;
	int count = 1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.countdownex);

		tv = (TextView) findViewById(R.id.countdowntvxxxxx);
		tv.setTextSize(size);

		startBtn = (Button) findViewById(R.id.countdownstartbtnxxxxx);
		stopBtn = (Button) findViewById(R.id.countdownstopbtnxxxxx);

		mTimer = new CountDownTimer(10 * 1000, 1000) {

			@Override
			public void onTick(long millisUntilFinished) {
				tv.setTextSize(size);
				tv.setText("" + count);
				count = count * 3;
				size += 4.0f;
			}

			@Override
			public void onFinish() {
				tv.setText("" + count);
				tv.setTextSize(size);
			}

		};

		startBtn.setOnClickListener(mClickListener);
		stopBtn.setOnClickListener(mClickListener);
	}

	View.OnClickListener mClickListener = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.countdownstartbtnxxxxx:
				mTimer.start();
				break;

			case R.id.countdownstopbtnxxxxx:
				mTimer.cancel();
				break;
			}
		}
	};
}
